﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.DynamicProxy;

namespace JackyCode.Mock
{
    public class MockObjectFactoryImpl<TEntity>:IMockObjectFactory<TEntity> where TEntity:class
    {
        private ProxyGenerator proxyGenerator = new ProxyGenerator();

        public TEntity CreateObject()
        {
            if (typeof(TEntity).IsClass)
            {
                return proxyGenerator.CreateClassProxy<TEntity>();
            }
            else if (typeof(TEntity).IsInterface)
            {
                return
                    proxyGenerator.CreateInterfaceProxyWithoutTarget<TEntity>();
            }
            return null;
        }
    }
}
